#ifndef __MY_MEM_H__
#define __MY_MEM_H__

#include <stdint.h>

#define ERR_FREE_BASE			0x1000
#define ERR_INVALID_PTR			(ERR_FREE_BASE + 1)		//!< invalid pointer for free
#define ERR_MEMBLK_FREE			(ERR_FREE_BASE + 2)		//!< memory block not used

#ifdef __cplusplus
extern "C" {
#endif

void MemInit(uint32_t baseAddr, uint32_t size);
void * MemMalloc(uint32_t size);
void MemFree(void * p);

void MemDump(const char * msg);

#define MEM_FREE(p)		do { MemFree(p); p = NULL; } while (0)

#ifdef __cplusplus
}
#endif

#endif // __MEM_H__

